package com.xiongtian.springframework.beans.factory;


import com.xiongtian.springframework.beans.BeansException;

/**
 * @Author: xiongtian
 * @CreateTime: 2025-03-24  11:09
 * @Version: 1.0
 * @Description: 代表Bean对象的工厂
 */

public interface BeanFactory {


    /**
     * 获取Bean
     *
     * @param beanName Bean名称
     * @return Bean对象
     * @throws BeansException 异常
     */
    Object getBean(String beanName) throws BeansException;

    /**
     * 获取有构造函数的Bean
     *
     * @param name Bean名称
     * @param args Bean构造函数参数
     * @return Bean对象
     * @throws BeansException 异常
     */
    Object getBean(String name, Object... args) throws BeansException;

    /**
     * 获取Bean
     * 根据名称和类型获取Bean
     *
     * @param name         Bean名称
     * @param requiredType Bean类型
     * @return Bean对象
     * @throws BeansException 异常
     */
    <T> T getBean(String name, Class<T> requiredType) throws BeansException;


    /**
     * 获取Bean
     * 根据类型获取Bean
     *
     * @param requiredType Bean类型
     * @return Bean对象
     * @throws BeansException 异常
     */
    <T> T getBean(Class<T> requiredType) throws BeansException;
}
